#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    string a,b,c;
    cin>>a>>b>>c;
    bool f=1;
    for(int i=0;i<4;i++)
    {
        unordered_map<char, int>m;
        m[a[i]]++,m[b[i]]++,m[c[i]]++;
        m[a[i+4]]++,m[a[i+8]]++,m[b[i+4]]++;
        if(m['Y']!=1||m['R']!=2||m['G']!=3)f=0;
    }
    cout<<(f?"YES":"NO")<<endl;
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}